package com.kmist.xiakexing.main;

import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.kmist.xiakexing.R;
import com.kmist.xiakexing.adapter.MainContentAdapter;
import com.kmist.xiakexing.main.base.BaseApplication;
import com.kmist.xiakexing.utils.Constants;

public class MainApplication extends BaseApplication implements View.OnClickListener {

    private Button menubar_btn01_jianghu;
    private Button menubar_btn02_lilian;
    private Button menubar_btn03_bag;
    private Button menubar_btn04_t1;
    private Button menubar_btn05_t2;
    private ViewPager jianghu_01_dynamicbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {

        menubar_btn01_jianghu = findViewById(R.id.menubar_btn01_jianghu);
        menubar_btn02_lilian = findViewById(R.id.menubar_btn02_lilian);
        menubar_btn03_bag = findViewById(R.id.menubar_btn03_bag);
        menubar_btn04_t1 = findViewById(R.id.menubar_btn04_test1);
        menubar_btn05_t2 = findViewById(R.id.menubar_btn05_test2);

        menubar_btn01_jianghu.setOnClickListener(this);
        menubar_btn02_lilian.setOnClickListener(this);
        menubar_btn03_bag.setOnClickListener(this);
        menubar_btn04_t1.setOnClickListener(this);
        menubar_btn05_t2.setOnClickListener(this);

        jianghu_01_dynamicbar = findViewById(R.id.jianghu_01_dynamicbar);

        //创建内容适配器
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        MainContentAdapter mainContentAdapter = new MainContentAdapter(supportFragmentManager);
        jianghu_01_dynamicbar.setAdapter(mainContentAdapter);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.menubar_btn01_jianghu:{jianghu_view();}break;
            case R.id.menubar_btn02_lilian:{lilian_view();}break;
            case R.id.menubar_btn03_bag:{packet_view();}break;
            case R.id.menubar_btn04_test1:{}break;
            case R.id.menubar_btn05_test2:{}break;
        }
    }
    private void jianghu_view() {
        jianghu_01_dynamicbar.setCurrentItem(Constants.INDEX_MAINWORLD);
    }

    private void lilian_view() {
        jianghu_01_dynamicbar.setCurrentItem(Constants.INDEX_UNDERWORLD);
    }
    private void packet_view() {
        jianghu_01_dynamicbar.setCurrentItem(Constants.INDEX_PACKETS);
    }

}